package com.itheima.work;

import java.util.Comparator;
import java.util.Map;
import java.util.TreeMap;

/**
 * @auther Macrydy
 * @date 2020/7/1 18:21
 * 使用map集合来存储3个键为学生对象(姓名,年龄,性别),值为学生的居住地名称的数据.
 * 要求学生对象按照年龄降序排列.
 */
public class Test3 {
    public static void main(String[] args) {
        Map<Student,String> map=new TreeMap<>(new Comparator<Student>() {
            @Override
            public int compare(Student o1, Student o2) {
                return o2.getAge()-o1.getAge();
            }

        });
        map.put(new Student("张三", 20, "男"), "北京");
        map.put(new Student("李四", 22, "男"), "上海");
        map.put(new Student("王五", 19, "男"), "南京");

        System.out.println(map);
    }
}
